<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>The Nature of Code</title>
  <script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
  <!-- <script type="text/javascript" src="../javascripts/codeprocessing.js"></script> -->
  <!-- <script type="text/javascript" src="../processingjs/processing.js"></script> -->
  <!-- <script type="text/javascript" src="../processingjs/lazyloading.js"></script> -->
  <script type="text/javascript" src="../javascripts/sketchControls.js"></script>
  <script type="text/javascript" src="../javascripts/jquery.fixed.js"></script>
  <script type="text/javascript" src="../javascripts/jquery.lazyloadxt.extra.min.js"></script>
  <script type="text/javascript" src="../javascripts/size-iframes.js"></script>

  <script type="text/javascript" charset="utf-8">
    $(document).ready(function(){
      $('#toc-list').fixed({'top':'8'});
      $('#nav-bar-wrap').fixed({'top':'8'});

      $('span.c1').each(function(){ addStylesToCodeLines($(this)); });
      // $('code').each(function(){ inlineComments($(this)); });
      $('div.source-code').each(function(){ setRawCodeHeight($(this)); });
      $('a.toggle').click(function(){ toggleCodeDisplay($(this)); return false; });
    });
  </script>
  <link rel="stylesheet" href="../stylesheets/fonts.css" type="text/css">
  <link rel="stylesheet" href="../stylesheets/html.css" type="text/css">
  <link rel="stylesheet" href="../stylesheets/code-html.css" type="text/css">

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-34673170-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

<script>

    window.onload= function() {
      offsetUps = document.getElementsByClassName('offset-up');
      for(var i=0; i < offsetUps.length; i++) {
        var element = offsetUps[i];
        var comment = element.getElementsByClassName('code-comment')[0];
        var height = comment.offsetHeight;
        comment.style.top = '-' + (height) +  'px';
      }
    };
</script>

</head>
<body>

  <div id="navigator">
    <div id="navigator-inner">
      <div id='nav-bar-wrap'>
        <div id="mask"></div>
        <div id="nav-bar">
          <h1><a href="/">THE <strong>NATURE</strong> OF CODE</a></h1>
          <h2>by Daniel Shiffman</h2>
          <a id="purchase-link" href="/">Buy this book in print</a> <a id="purchase-link" href="/">Buy this book as PDF</a>
        </div>
      </div>
      <div id="toc-holder">
        <div id="toc-list">
          <ul>
            <li><a href="/book/">Welcome</a></li>
            <li><a href="/book/acknowledgments">Acknowledgments</a></li>
            <li><a href="/book/dedication">Dedication</a></li>
            <li><a href="/book/preface">Preface</a></li>
            <li><a href="/book/introduction">Introduction</a></li>
            <li><a href="/book/chapter-1-vectors">1.  Vectors</a></li>
            <li><a href="/book/chapter-2-forces">2.  Forces</a></li>
            <li><a href="/book/chapter-3-oscillation">3.  Oscillation</a></li>
            <li><a href="/book/chapter-4-particle-systems">4.  Particle Systems</a></li>
            <li><a href="/book/chapter-5-physics-libraries">5.  Physics Libraries</a></li>
            <li><a href="/book/chapter-6-autonomous-agents">6.  Autonomous Agents</a></li>
            <li><a href="/book/chapter-7-cellular-automata">7.  Cellular Automata</a></li>
            <li><a href="/book/chapter-8-fractals">8.  Fractals</a></li>
            <li><a href="/book/chapter-9-the-evolution-of-code">9.  The Evolution of Code</a></li>
            <li><a href="/book/chapter-10-neural-networks">10.  Neural Networks</a></li>
            <li><a href="/book/further-reading">Further Reading</a></li>
            <li><a href="/book/index">Index</a></li>
          </ul>
        </div>
      </div>
    </div>
  </div>

  <div id="top">
    <div id="header">
      <h1><a href="/">The <strong>Nature</strong> of Code</a></h1>
      <h2>Daniel Shiffman</h2>
    </div>
  </div>

  <div id="middle">
    <div id="container">
      {{ content }}
    </div>
  </div>

  <div id="bottom">
    <div id="footer">
      <div class="one-third" id="licenses">
        <h4>Licenses</h4>
        <p>
          <a class="license-badge" rel="license" href="http://creativecommons.org/licenses/by-nc/3.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc/3.0/88x31.png" /></a>
          <a class="license-badge" rel="license" href="http://creativecommons.org/licenses/LGPL/2.1/"><img alt="LGPL License" style="border-width:0" src="http://www.gnu.org/graphics/lgplv3-88x31.png" /></a>
        </p>

        <p>
          The book's text and illustrations are licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc/3.0/">Creative Commons Attribution-NonCommercial 3.0 Unported License</a>.
        </p>

        <p>
          All of the book's source code is licensed under the <a rel="license" href="http://creativecommons.org/licenses/LGPL/2.1/">GNU Lesser General Public License</a> as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
        </p>

      </div>

      <div class="one-third">
        <h4>Colophon</h4>

        <p>This book was generated with <a href="https://github.com/runemadsen/Magic-Book-Project">The Magic Book Project</a>.

        <p>This book would not have been possible without the generous support of <a href="http://www.kickstarter.com/projects/shiffman/the-nature-of-code-book-project">Kickstarter</a> backers.</p> 

        <p>This book is typeset on the web in Georgia with headers in Proxima Nova.</p>

        <p>Please report any mistakes in the book or bugs in the source with a <a href="https://github.com/shiffman/The-Nature-of-Code/issues?sort=created&state=open">GitHub issue</a> or contact me at <span class="eml">daniel at shiffman dot net</span>.</p>
      </div>

      <div class="one-third">
        <h4>Author</h4>
        <p>Daniel Shiffman is a professor of the <a href="http://itp.nyu.edu/">Interactive Telecommunications Program</a> at New York University.</p>

        <p>He is the author of <a href="http://www.learningprocessing.com/">Learning Processing</a>.</p>

        <p><a href="https://twitter.com/shiffman">Twitter</a> <a href="http://github.com/shiffman">GitHub</a></p>
      </div>
    </div>
  </div>
  </body>
</html>
